import { ref } from 'vue'
const useList = () => {
  // 列表渲染
  const list = ref([
    { id: 0, name: '吃饭', ok: false },
    { id: 1, name: '睡觉', ok: false }
  ])
  // 删除
  const del = (i) => {
    list.value.splice(i, 1)
  }
  // 新增
  const name = ref('')
  const add = () => {
    if (!name.value) return
    list.value.unshift({
      id: Date.now(),
      name: name.value,
      ok: false
    })
    name.value = ''
  }
  return { list, del, name, add }
}
export { useList }
